Repository navigation
first-message-thinking: count the page free at its next frame too, not only its next task - #2662
Merged
Merged
Conversation
…t only its next task
davidmckayv
marked this pull request as ready for review
December 1, 2026 22:49
davidmckayv
requested review from
MikeRyanDev,
dustywusty,
guidovizoso,
mxmzb,
samjulien and
tylerslaton
as code owners
December 1, 2026 22:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Fixes #2389
Fixes #2396
first-message-thinking.test.tsxchecks that "Thinking" is in the page, and the page is free to draw it, within 200 ms of Send. It knocked pull requests out of the merge queue three times on 1 Dec: #2504 and #2642 (a starter task on a new conversation with a Bot, WebKit, 258 ms and 274 ms) and #2631 (home, Chromium, 267 ms).Part of the cause is where the test stopped the clock. It took the page as free when its next task ran: a
MessageChannelmessage posted once the line was in. After a click or a key press, the browser draws a frame first, and that message waits behind the frame. So the 200 ms the test gave the page also held the browser's own frame, which is exactly the time a loaded runner stretches. The test's own comments already say that frame wait is not the page's to shorten. Under CI's load, every slow send in the repeat runs below had that frame inside the measured time, worth up to 48 ms.A frame begins only once the page's task is over, so the first frame read after the line is in marks the page free just as well. The test now takes whichever comes first, the next task or that frame. The 200 ms bound is unchanged, and so is everything else it checks: every frame from then on shows "Thinking" until the Bot's first words. When the bound is missed, the log now says where the time went (in, free, first drawn), so the next miss can be read straight off CI.
Thanks to @ykakade for #2572, which went after the same tests by changing where they start. Its renderer crash is now caught by
renderer-crash.ts, which reruns a test whose WebKit page crashed: there were no crash reruns in 96 runs of the file under CI's load. The timing misses also happen away from Home and in Chromium, so this measures the page from the right moment instead of changing Home.Where it runs
Only the browser test changes. No new state, no second-replica behaviour, nothing serialised, no fan-out, no listener, port or schedule.
Boundary and audit
API and database
api/, no app's requests, no database change and norelease-policy.json.Changelog
Proof
Under CI's own load, repeated. Draft #2657, which will not be merged, ran CI's exact WebKit-job list (8 files at once, Chromium and WebKit, the Playwright image,
openbot-ubuntu-16core) in 12 shards, each with 3 extra copies of this file: 48 full runs of the file per engine, 288 sends per engine, for each version.Page's own time from Send, in ms:
With the fix, all 96 runs passed, with no renderer crash reruns. WebKit's worst case now has 50 ms of room under the bound, up from 19 ms. Neither 48-run sample happened to catch a miss before the fix, so the proof is that room, plus the frame time it removes, not a failure count flipping.
What this does not prove: the CI logs of the 1 Dec misses don't say how their 258 to 274 ms split, and the frame this removes was worth up to 48 ms in these samples. The rest of the time is the app's own work (putting the line in), which a loaded runner slows 4 to 5 times over (in at up to 146 ms here, against 15 to 35 ms on an unloaded machine). If a miss comes back, its log now gives that split, and the next step can be chosen from it.
Still catches a real delay. With "Thinking" delayed 300 ms in the app itself (before
setSenton a new conversation, and before Home'snavigateto the placeholder), every delayed case failed in both engines, at 313 to 371 ms:The existing test where the page stays busy for 400 ms once "Thinking" is in still misses the bound in both engines. Nothing can draw until that busy task ends, so the frame end point cannot hide it.
Local runs were single and unloaded (Chromium and WebKit, 16 pass); the repeated runs under load were on CI.